﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CallCenter.BLL;

namespace CallCenter
{
    public partial class FormChangePassword : Form
    {
        public FormChangePassword()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string oldPwd = txtOldPwd.Text;
            string newPwd = txtNewPwd.Text;
            string reNewPwd = txtReNewPwd.Text;
            if (newPwd != reNewPwd)
            {
                MessageBox.Show("两次输入密码不一致，重新输入");
            }
            else
            {
                SeatsBLL bll = new SeatsBLL();
                try
                {
                    if (bll.ChangePassword(Global.CurrentSeatId, oldPwd, newPwd))
                    {
                        MessageBox.Show("修改成功");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("原密码输入错误");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("出现异常:" + ex.Message);
                }
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
